package cn.ncupyh.soft;

import java.util.Scanner;

public class CarTest {
    public static void main(String[] args) {
//        创建数组
        Car[] arr = new Car[3];
//        创建输入对象
        Scanner sc = new Scanner(System.in);
        for (int j = 0; j < arr.length; j++) {
//         创建类的对象
            Car c = new Car();
            //brand
            System.out.println("请输入第" + (j+1) + "个商品的brand:");
            String brand = sc.next();
            c.setBrand(brand);
            //price
            System.out.println("请输入第" + (j+1) + "个商品的price:");
            int price = sc.nextInt();
            c.setPrice(price);
            //color
            System.out.println("请输入第" + (j+1) + "个商品的color:");
            String color = sc.next();
            c.setColor(color);
//          录入数组
            arr[j] = c;
        }


        for (int i = 0; i < arr.length; i++) {
            Car car = arr[i];//重定义方便书写与理解
            System.out.println(car.getBrand() + "," + car.getPrice() + "," + car.getColor() + "," );
        }
    }
}
